package com.smsc.headend.task.engine.mapper.provider;

import cn.hutool.core.date.SystemClock;
import com.smsc.headend.module.scheme.entity.ConfigAutoRecollectTask;

public class ConfigAutoRecollectTaskProvider {

    public String updateTask(ConfigAutoRecollectTask autoRecollectTask) {
        StringBuilder sb = new StringBuilder("UPDATE CONFIG_AUTO_RECOLLECT_TASK SET TASK_STATUS = #{status}, TV_LAST_COLL = #{tvLastColl} ");
        sb.append(", TV_UPDATE= " + SystemClock.now() / 1000);
        if (autoRecollectTask.getDataDetail() != null) {
            sb.append(", DATA_DETAIL=#{dataDetail} ");
        }
        if (autoRecollectTask.getExecutedTimes() != null) {
            sb.append(", EXECUTED_TIMES=#{executedTimes} ");
        }
        if (autoRecollectTask.getTvDataLow() != null) {
            sb.append(", TV_DATA_LOW=#{tvDataLow} ");
        }
        if (autoRecollectTask.getTvDataHigh() != null) {
            sb.append(", TV_DATA_HIGH=#{tvDataHigh} ");
        }
        if (autoRecollectTask.getDataPoints() != null) {
            sb.append(", DATA_POINTS=#{dataPoints} ");
        }
        sb.append(" WHERE SEQ = #{seq}");
        return sb.toString();
    }
}
